﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:validation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
             xmlns:localValidation="clr-namespace:Rio.Manager.Application.Utils.Validation"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:behaviors="clr-namespace:Rio.Manager.Application.Behaviors"
             xmlns:mvvmLightCommand="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
             xmlns:Control="clr-namespace:Rio.Framework.Pages.Controls;assembly=Rio.Framework.Pages"
             x:Class="Rio.Manager.Application.Views.VersioningModelTabView"
             mc:Ignorable="d"
             Margin="0">

    
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Rio.Manager.Application;component/Skins/VersioningModelTabSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <UserControl.DataContext>
        <Binding Path="VersioningModelTab"
                 Source="{StaticResource Locator}" />
    </UserControl.DataContext>

    <Grid x:Name="LayoutRoot">
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Loaded">
                <mvvmLightCommand:EventToCommand Command="{Binding InitializationCommand}" />
            </i:EventTrigger>
        </i:Interaction.Triggers>

        <Grid Margin="0"
              HorizontalAlignment="Center"
              VerticalAlignment="Center">

            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>

            <StackPanel d:LayoutOverrides="Width">
                <Control:BindableOrganizationFolderTypePanel Mode="Admin"
                                                             SelectedOrganization="{Binding SelectedOrganization, Mode=TwoWay}"
                                                             SelectedFolderType="{Binding SelectedFolderType, Mode=TwoWay}"
                                                             Margin="0,10,0,0"
                                                             HorizontalAlignment="Left"
                                                             OrganizationLabel="{Binding OrganizationLabel}"
                                                             FolderTypeLabel="{Binding FolderTypeLabel}" />
            </StackPanel>
            <StackPanel Grid.Row="1"
                        d:LayoutOverrides="Width"
                        Margin="0,20,0,0"
                        VerticalAlignment="Center">
                <TextBlock TextWrapping="Wrap"
                           Text="{Binding VersionModelLabel}"
                           FontWeight="Bold"
                           Margin="0,0,0,10" />
                <StackPanel Orientation="Horizontal"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center">
                    <Image Width="26"
                           Height="26"
                           Margin="10,0,0,0"
                           Source="/Rio.Manager.Application;component/Assets/Images/version.png"
                           Stretch="UniformToFill" />
                    <StackPanel Height="26"
                                Orientation="Horizontal"
                                Margin="5,0,0,0">
                        <ComboBox x:Name="cbModelVersion"
                                  DisplayMemberPath="Name"
                                  UseLayoutRounding="True"
                                  ItemsSource="{Binding Models}"
                                  SelectedValue="{Binding SelectedDisplayVersionType, Mode=TwoWay}"
                                  Width="260"
                                  VerticalAlignment="Center"
                                  Height="26"
                                  IsEnabled="{Binding SelectedFolderIdentifier, Converter={StaticResource LongToEnabledConverter}}" />
                    </StackPanel>
                </StackPanel>
            </StackPanel>
            <StackPanel Orientation="Vertical"
                        Grid.Row="2"
                        d:LayoutOverrides="Height"
                        Margin="0"
                        VerticalAlignment="Center"
                        Visibility="Collapsed">
                <CheckBox Content="{Binding ApprobalOptionLabel}"
                          FontWeight="Bold"
                          IsChecked="{Binding UseApprobalOption, Mode=TwoWay}"
                          Margin="10,0,0,0" />
                <ComboBox x:Name="cbWorkflow"
                          SelectedValue="{Binding ApprovalWkfID, Mode=TwoWay}"
                          Margin="45,10,0,0"
                          Width="260"
                          IsEnabled="{Binding UseApprobalOption, Mode=TwoWay}"
                          HorizontalAlignment="Left"
                          Height="26" />
            </StackPanel>
            <StackPanel Grid.Row="3"
                        d:LayoutOverrides="Width"
                        Margin="0,50,0,0"
                        VerticalAlignment="Center"
                        Grid.ColumnSpan="2">
                <TextBlock TextWrapping="Wrap"
                           Text="{Binding StorageSpaceLabel}"
                           FontWeight="Bold"
                           Margin="0,0,0,20" />
                <Grid HorizontalAlignment="Left"
                      Margin="10,0,0,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="0.505*" />
                        <RowDefinition Height="0.495*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0.220*" />
                        <ColumnDefinition Width="0.780*" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="1"
                               TextWrapping="Wrap"
                               Text="{Binding LastMajorVersionsSaved}"
                               VerticalAlignment="Center"
                               Margin="5,0,0,0" />
                    <TextBlock Grid.Column="1"
                               TextWrapping="Wrap"
                               Text="{Binding LastMajorMinorVersionsSaved}"
                               Grid.Row="1"
                               VerticalAlignment="Center"
                               Margin="5,0,0,0" />
                    <telerik:RadNumericUpDown x:Name="UpDownVersionMajor"
                                              NumberDecimalDigits="0"
                                              Width="50"
                                              VerticalAlignment="Center"
                                              HorizontalAlignment="Right"
                                              Value="{Binding MaxMajorVersions, Mode=TwoWay}"
                                              IsEnabled="{Binding IsUpDownVersionMajorEnabled, Mode=TwoWay}"
                                              Minimum="1" />
                    <telerik:RadNumericUpDown x:Name="UpDownVersionMinor"
                                              NumberDecimalDigits="0"
                                              Grid.Row="1"
                                              Width="50"
                                              VerticalAlignment="Center"
                                              HorizontalAlignment="Right"
                                              Value="{Binding MaxMinorVersions, Mode=TwoWay}"
                                              IsEnabled="{Binding IsUpDownVersionMinorEnabled, Mode=TwoWay}"
                                              Minimum="1"
                                              Margin="0,5,0,0" />
                </Grid>
            </StackPanel>
            <StackPanel Orientation="Horizontal"
                        VerticalAlignment="Center"
                        HorizontalAlignment="Right"
                        Grid.Row="4"
                        Margin="0,50,0,0"
                        Grid.ColumnSpan="2">
                <Button x:Name="btnValid"
                        Content="Valider"
                        Width="100"
                        VerticalAlignment="Bottom"
                        Command="{Binding CreateModelCommand}" />
            </StackPanel>
            <Border BorderBrush="#FF00527E"
                    BorderThickness="1"
                    Grid.Column="1"
                    Margin="10,0"
                    CornerRadius="5"
                    Padding="0"
                    Width="350"
                    Grid.RowSpan="2"
                    HorizontalAlignment="Center"
                    MaxHeight="150"
                    VerticalAlignment="Bottom">
                <Border.Effect>
                    <DropShadowEffect BlurRadius="10"
                                      ShadowDepth="0"
                                      Opacity="0.4" />
                </Border.Effect>
                <Border.Background>
                    <RadialGradientBrush>
                        <GradientStop Color="#FFD8D7B7"
                                      Offset="0" />
                        <GradientStop Color="#FFFFFDCE"
                                      Offset="1" />
                    </RadialGradientBrush>
                </Border.Background>
                <Grid Margin="0,0,3,3"
                      d:LayoutOverrides="Width, Height">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="25" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="25" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Image Source="/Rio.Manager.Application;component/Assets/Images/help.png"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Width="16" />
                    <TextBlock Grid.Column="1"
                               TextWrapping="Wrap"
                               Text="{Binding SelectedDisplayVersionType.Name}"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Margin="5,0,0,0"
                               FontWeight="Bold"
                               FontStyle="Italic" />
                    <ScrollViewer Grid.Column="1"
                                  Margin="0,5,0,0"
                                  Grid.Row="1"
                                  BorderThickness="0"
                                  ScrollViewer.VerticalScrollBarVisibility="Auto">
                        <TextBlock TextWrapping="Wrap"
                                   Text="{Binding DescriptionLabel}" />
                    </ScrollViewer>
                </Grid>
            </Border>

        </Grid>

        <telerik:RadBusyIndicator IsBusy="{Binding BusyIndicator.IsBusy}"
                                  IsIndeterminate="True" />
    </Grid>
</UserControl>
